package com.lgh.springframework.test.bean;

import com.lgh.springframework.beans.BeansException;
import com.lgh.springframework.beans.factory.*;
import com.lgh.springframework.context.ApplicationContext;
import com.lgh.springframework.context.ApplicationContextAware;

/**
 * ******************************************************
 *
 * @author liugh9
 * @version 1.0
 * @classname UserService
 * @description
 * @date 2023/02/21 21:30
 * <p>
 * ******************************************************
 */
public class UserService implements BeanFactoryAware, BeanNameAware, ApplicationContextAware, BeanClassLoaderAware {

    private ApplicationContext applicationContext;
    private BeanFactory beanFactory;

    private String userId;
    private String company;
    private String location;
    private UserDao userDao;

    @Override
    public void setBeanFactory(BeanFactory beanFactory) throws BeansException {
        System.out.println("setBeanFactory.........");
        this.beanFactory = beanFactory;
    }

    @Override
    public void setApplicationContext(ApplicationContext applicationContext) throws BeansException {
        System.out.println("setApplicationContext........");
        this.applicationContext = applicationContext;
    }

    @Override
    public void setBeanName(String name) {
        System.out.println("Bean Name is：" + name);
    }

    @Override
    public void setBeanClassLoader(ClassLoader classLoader) {
        System.out.println("ClassLoader：" + classLoader);
    }

    public String queryUserInfo() {
        return userDao.queryUserName(userId) + ", 公司：" + company + ", 地点" + location;
    }

    public ApplicationContext getApplicationContext() {
        return applicationContext;
    }

    public BeanFactory getBeanFactory() {
        return beanFactory;
    }

    public String getUserId() {
        return userId;
    }

    public void setUserId(String userId) {
        this.userId = userId;
    }

    public UserDao getUserDao() {
        return userDao;
    }

    public void setUserDao(UserDao userDao) {
        this.userDao = userDao;
    }

    public String getCompany() {
        return company;
    }

    public void setCompany(String company) {
        this.company = company;
    }

    public String getLocation() {
        return location;
    }

    public void setLocation(String location) {
        this.location = location;
    }

}
